package com.example.practicespring.service.impl;

import cn.dev33.satoken.stp.StpInterface;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.practicespring.domain.User;
import com.example.practicespring.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

@Slf4j
@Component
public class StpInterfaceImpl implements StpInterface {

    @Resource
    private UserService userService;

    @Override  
    public List<String> getPermissionList(Object loginId, String loginType) {
        // 根据loginId和loginType从数据库或缓存中获取用户的权限码集合  
        // 这里只是示例，实际项目中需要根据业务逻辑来实现  
        return Arrays.asList("user:add", "user:delete", "admin:view");
    }  
  
    @Override  
    public List<String> getRoleList(Object loginId, String loginType) {  
        // 根据loginId和loginType从数据库或缓存中获取用户的角色标识集合  
        // 这里只是示例，实际项目中需要根据业务逻辑来实现
        log.info("loginId: {}, loginType: {}", loginId, loginType);

        return userService.selectRolesByUserId(Long.parseLong(loginId.toString()));
    }  
}